<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>面向对象-闭包</title>
</head>

<script>
//    用闭包完成js面向对象之私有属性

    function Girl(name,bf) {

        var secret = bf;

        this.name = name;
//        通过showlove 做接口读取私有属性
        this.showLove = function(){
            return secret;
        }

        this.moveLove = function(){
            secret = "薛蟠"
            return secret;
        }
    }

    var girl = new Girl("林黛玉","贾宝玉");

    alert(girl.showLove())
    alert(girl.moveLove())


</script>
<body>

</body>
</html>

